package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.tangyh.basic.base.R;
import top.tangyh.lamp.care.entity.BHl7Event;
import top.tangyh.lamp.care.service.BHl7EventService;
import top.tangyh.lamp.care.service.BHl7YzService;
import top.tangyh.lamp.care.service.TemperatureService;
import top.tangyh.lamp.care.vo.result.HuxiJiHaveOfSwithRVO;
import top.tangyh.lamp.care.vo.result.TemperatureDataVO;
import top.tangyh.lamp.common.constant.EventEnum;

import java.util.Date;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@Tag(name = "系统：体温单")
@RequestMapping("/temperature")
public class TemperatureController {

    private final TemperatureService temperatureService;
//    private final YxRespiratorStatusService yxRespiratorStatusService;

    private final BHl7YzService bHl7YzService;


    private final BHl7EventService bHl7EventService;


    @GetMapping("/list")
    @Operation(summary = "查询体温单相关数据")
    public R<TemperatureDataVO> getTemperatureDatas(@Parameter(description = "住院号", required = true) @RequestParam String hospitalNumber,
                                                    @Parameter(description = "病人识别号", required = true) @RequestParam String patientIdent,
                                                    @Parameter(description = "入科时间") @RequestParam(required = false) Long rkTime,
                                                    @Parameter(description = "出科时间") @RequestParam(required = false) Long ckTime) {
        //入科时间
//        BHl7Event yxHl7EventPORk = bHl7EventService.selectOneByEventTypeHospitalNumber(EventEnum.RK.getEventType(), hospitalNumber);
//        //出科时间
//        BHl7Event yxHl7EventPOCY = bHl7EventService.selectOneByEventTypeHospitalNumber(EventEnum.CK.getEventType(), hospitalNumber);

        TemperatureDataVO data = temperatureService.getTemperatureDatas(patientIdent, hospitalNumber,  rkTime, ckTime);
        return R.success(data);
    }


//    @GetMapping("/respirator/switch")
//    @Operation(summary ="操作呼吸机R标识开关")
//    public R<Integer> openOrClose(@Parameter(description = "住院号", required = true) @RequestParam String hospitalNumber,
//                                     @Parameter(description = "病人识别号", required = true) @RequestParam String patientIdent,
//                                     @Parameter(description = "操作类型", required = true) Integer operation,
//                                     @Parameter(description = "操作时间") @RequestParam(required = true) Long operationTIme) {
//        int result = yxRespiratorStatusService.openOrClose(operation, hospitalNumber, patientIdent, operationTIme);
//        return R.success(result);
//    }


//    @GetMapping("/respirator/switch/allstatus")
//    @Operation(summary ="获得当前观察项时间点的按钮状态")
//    public R<List<HuxiJiHaveOfSwithRVO>> getThisTimeOfSwitchStatus(@Parameter(description = "住院号", required = true) @RequestParam String hospitalNumber,
//                                                                   @Parameter(description = "病人识别号", required = true) @RequestParam String patientIdent, @Parameter(description = "入科时间")@RequestParam Long rkTime) {
//        List<HuxiJiHaveOfSwithRVO> huxiJiHaveRVOList = yxRespiratorStatusService.getHandRListOfSwitch(hospitalNumber, new Date(rkTime));
//
//
//        return R.success(huxiJiHaveRVOList);
//    }


}